package com.lijy.list;


import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.PriorityQueue;

public class PriorityQueueTest {
    public static void main(String[] args) {
        PriorityQueue<GregorianCalendar> pq = new PriorityQueue<GregorianCalendar>();
        pq.add(new GregorianCalendar(1991, Calendar.DECEMBER, 9));
        pq.add(new GregorianCalendar(1990, Calendar.DECEMBER, 8));
        pq.add(new GregorianCalendar(1992, Calendar.DECEMBER, 3));
        pq.add(new GregorianCalendar(1998, Calendar.JUNE, 9));

        System.out.println("Iterator over elements....");

        for (GregorianCalendar date : pq) {
            System.out.println(date.get(Calendar.YEAR));
        }

        System.out.println("Removing elements.....");
        while (!pq.isEmpty()) {
            System.out.println(pq.remove().get(Calendar.YEAR));
        }


    }
}
